<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/templates/common/taglib.jsp"%>

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>${title }</title>
<link href="${basePath}/static/css/basic.css" rel="stylesheet"
	type="text/css">
<link href="${basePath}/static/css/login.css" rel="stylesheet"
	type="text/css">
<script type="text/javascript"
	src="${basePath}/static/js/jquery-1.7.2.min.js"></script>
<script  type="text/javascript" src="${basePath}/static/layer/layer.js"></script>
<link href="${basePath}/static/layer/layer_defined.css" rel="stylesheet" type="text/css">
<style>
body{
   background:url(${basePath}/static/images/managerLogin-background.png) no-repeat; 
}
#box {
	width: 1200px;
	/* height: 1000px; */
	margin: 200px auto 0;
}
</style>
</head>
<body>
  
	<!--<div id="div_login" style="display:none;">-->
	<div id="box">
		<div id="div_login">
			<div class="login">
				<form action="${basePath}/user/userLogin" method="post" id="form1">
					<ul>		
					
						<li>
						<p style="width: 65px; float: left;">用户名：</p>
						<p style="float: left; width: 100px;">
						<INPUT style="float: none;" name="loginName"id="username" type="text" class="textbox" value="">
						</p>
						</li>
						
						<li>
							<p style="width: 65px; float: left;">密&nbsp;&nbsp; 码：</p>
							<p style="float: left; width: 100px;">
								<INPUT style="float: none;" name="password"
								id="password" type="password" class="textbox" value="">
							</p>
						</li>
						<li><span onclick="createCode()" style="letter-spacing:5px" id="checkCode"></span>验证码：<INPUT name="txtName" id="txtName" type="text" class="check" value=""></li>

						<!-- <li>机 构：<select style="float: none;" name="orgCode"
							style="width:220px;"><option value="49557184-0">山东省立医院</option></select></li> -->
						<li><a><INPUT name="btnLogin" class="L_up" id="btn_login" onclick="login()"
								type="button" value="登&nbsp;&nbsp;录"></a> <a><INPUT
								name="btnLogin" class="L_up2" id="closeBtn" type="button"
								value="清&nbsp;&nbsp;空"></a></li>
					</ul>
				</form>
			</div>
		</div>
	</div>
	
	<script type="text/javascript">
	$("#closeBtn").on('click',function(){
		$("#username").val("");
		$("#password").val("");
		$("#txtName").val("");
		createCode();
	});
	
	$(function(){
		createCode();
	});
	
	var code; //在全局 定义验证码    
	function createCode() {  
	        code = "";  
	        var codeLength = 4;//验证码的长度       
	  
	        var selectChar = new Array(2, 3, 4, 5, 6, 7, 8, 9, 'A', 'B', 'C', 'D',  
	                'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R',  
	                'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');  
	  
	        for (var i = 0; i < codeLength; i++) {  
	            var charIndex = Math.floor(Math.random() * 32);  
	            code += selectChar[charIndex];  
	        }  
	        if (code.length != codeLength) {  
	            createCode();  
	        }  
	        $("#checkCode").html(code);  
	    }  
	  
	    function validate() {  
	        var inputCode = document.getElementById('txtName').value.toUpperCase();
	        if (inputCode.length <= 0) {  
	            layer.alert("请输入验证码！",{icon:0});  
	            return false;  
	        } else if (inputCode != code) {  
	        	layer.alert("验证码输入错误！",{icon:0});  
	            createCode();  
	            return false;  
	        } else {  
	            return true;  
	        }  
	  
	    }  
	     
	    function login(){
	    	var userName= $("#username").val();
	    	var password=$("#password").val();
	    	if(!userName){
	    		layer.alert("用户名不能为空!",{icon:0});
	    		return;
	    	}
	    	if(!password){
	    		layer.alert("密码不能为空!",{icon:0});
	    		return;
	    	}
	    	
	    	//校验验证码登陆
	    	if(validate()){
	    		$("#form1").submit();
	    	}
	    	
	    }
	
	</script>
</body>
</html>
